package cn.mumzone.pos.ui.activity;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.EditText;

import butterknife.BindView;
import butterknife.OnClick;
import cn.mumzone.basic.base.BaseActivity;
import cn.mumzone.basic.loading.button.LoadingButton;
import cn.mumzone.basic.util.ToastUtil;
import cn.mumzone.pos.R;
import cn.mumzone.pos.presenter.UpReturnMoneyAuthPresenter;
import cn.mumzone.pos.presenter.contract.UpReturnMoneyAuthContract;

/**
 * Created by JoeLjt on 2019/7/19.
 * Email: lijiateng1219@gmail.com
 * Description:
 */

public class ACT_UpReturnMoneyAuth extends BaseActivity<UpReturnMoneyAuthPresenter> implements UpReturnMoneyAuthContract.View {

    public static final int REQUEST_CODE_AUTH = 102;

    @BindView(R.id.et_auth_phone)
    EditText etPhone;
    @BindView(R.id.et_auth_pwd)
    EditText etPassword;
    @BindView(R.id.lb_auth)
    LoadingButton lbAuth;

    @Override
    public void showAuthSuccess() {
        lbAuth.stopLoading("授权成功");
        ToastUtil.makeText(mContext,"授权成功",false);
        setResult(Activity.RESULT_OK);
        finish();
    }

    @Override
    public void showError(String msg) {
        super.showError(msg);
        lbAuth.stopLoading("确认授权");
    }

    @Override
    protected void initEventAndData() {

    }

    @OnClick({R.id.iv_cancel,R.id.lb_auth})
    void onViewClicked(View view){
        switch (view.getId()){
            case R.id.lb_auth:
                lbAuth.startLoading("正在授权");
                mPresenter.verifyReturnAuth(etPhone.getText().toString().trim(),etPassword.getText().toString().trim());
                break;
            case R.id.iv_cancel:
                setResult(Activity.RESULT_CANCELED);
                finish();
                break;
        }
    }

    public static void startAcForResult(Activity activity,int requestCode){
        Intent intent = new Intent(activity,ACT_UpReturnMoneyAuth.class);
        activity.startActivityForResult(intent,requestCode);
    }

    @Override
    protected boolean toggleOverridePendingTransition() {
        return false;
    }

    @Override
    protected int getLayout() {
        return R.layout.act_up_return_money_auth;
    }
}
